package com.kjsdfgk.hjmdsf.play.mvp.model;

import android.app.Application;
import android.util.Base64;

import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import com.jess.arms.di.scope.ActivityScope;

import javax.inject.Inject;

import com.kjsdfgk.hjmdsf.app.api.service.CommonService;
import com.kjsdfgk.hjmdsf.ftvdolist.mvp.bean.XJLookResult;
import com.kjsdfgk.hjmdsf.play.mvp.contract.MyPlayVideoContract;

import io.reactivex.Observable;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 04/10/2020 12:30
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
@ActivityScope
public class MyPlayVideoModel extends BaseModel implements MyPlayVideoContract.Model {
    @Inject
    Gson mGson;
    @Inject
    Application mApplication;

    @Inject
    public MyPlayVideoModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<XJLookResult> lookVod(String uid, int vod_id) {
        String url = "aHR0cDovL2FwcC54amxiNC5jb20vYXBpLnBocC9hcHBfMi9sb29rVm9k";//"http://app.xjlb4.com/api.php/app_2/lookVod";
        url = new String(Base64.decode(url.getBytes(), Base64.DEFAULT));
        Observable<XJLookResult> result = mRepositoryManager.obtainRetrofitService(CommonService.class).
                lookVod(url , uid,  String.valueOf(vod_id));
        return result;
    }

    @Override
    public Observable<String> ccyyHtml(String href) {

        Observable<String> result = mRepositoryManager.obtainRetrofitService(CommonService.class)
                .ccyyHtmlApi( href );

        return result;
    }
}